//
//  TimeTool.swift
//  YYMusicDemo
//
//  Created by yuanyue on 2018/4/28.
//  Copyright © 2018年 yuanyue. All rights reserved.
//

import UIKit

class TimeTool: NSObject {
    
    class func getFormetTimer(timer : TimeInterval) -> String {
        let min = Int(timer / 60)
        let sec = Int(timer.truncatingRemainder(dividingBy: 60))
        return String(format: "%02d:%02d", min,sec)
        
    }
    
    class func getFormetString(str : String) -> TimeInterval {
        
        let min = str.components(separatedBy: ":")
        if min.count != 2 {
            return 0
        }
        let minTime = Int(min[0]) ?? 0
        let secTime = Int(min[1]) ?? 0
        
        return TimeInterval(minTime * 60 + secTime)

    }
}
